//
//  BRTopUpHistoryCell.m
//  BrezzeSaaS
//
//  Created by IOS on 2021/10/14.
//  Copyright © 2021 Brezze GWG. All rights reserved.
//

#import "BRTopUpHistoryCell.h"

@implementation BRTopUpHistoryCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.amount.font = [UIFont fontB:20];
    self.amount.textColor = kColorTitle;
    self.statusL.font = [UIFont fontS:17];
    self.statusL.textColor = kColorTitle;
    self.fromL.font = [UIFont fontM:13];
    self.fromL.textColor = kColorTitle66B;
    self.timeL.font = [UIFont fontM:13];
    self.timeL.textColor = kColorTitle66B;
    
    self.amount.textAlignment = NSTextAlignmentRight;
    
    self.bgView.backgroundColor = UIColor.whiteColor;
    self.bgView.layer.cornerRadius = 10;
    self.bgView.layer.masksToBounds = YES;
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
//    self.rentLogo.hidden = YES;
    
}

- (void)detailClick {
    if (self.detailClickBlock) self.detailClickBlock();
}


- (void)setDto:(BRDealFlowModel *)dto {
    _dto = dto;

    NSString *positiveStr = @"-";
//    if ([self isPositive:dto.type]) {
//        positiveStr = @"";
//    }
    [self isRefund:dto.refund == 1];
    self.amount.text = [NSString stringWithFormat:@"%@%@",positiveStr,[BRPayManager br_amount:dto.amount]];
    self.timeL.text = [BRTools getTimeFromTimestamp:dto.createTime.integerValue formatter:kBRDateFormatterdMy];
    
    NSString *payWithStr = @"--";
    if (!BR_StringIsEmpty(dto.paymentMethod)) {
        payWithStr = [BRTools payWith:[dto.paymentMethod integerValue]];
    }
    
    if ([dto.paymentMethod integerValue] <= 1 && ![payWithStr isEqualToString:@"--"]) {
        // 如果是卡支付添加卡后4位显示
        if (self.dto.bankNo.length != 0) {
            payWithStr = [NSString stringWithFormat:@"%@(%@)",payWithStr,self.dto.bankNo];
        }
    }
    self.fromL.text = payWithStr;
    
    
    self.statusL.text = [BRTools paymentType:dto.type];
}

- (void)isRefund:(BOOL)isRefund {
    
    self.rentLogo.hidden = !isRefund;
}

- (BOOL)isPositive:(NSInteger)type {
    
    if (type %2 == 0) {
        return YES;
    }
    
    return NO;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
